package com.atguigu.gulimall.search.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @program: gulimall
 * @description: es配置类
 * @author: liuxvru
 * @create: 2024-02-29 18:48
 **/
@Configuration
public class GulimaillElasticSearchConfig {
    @Value("${elasticsearch.host}")
    private String host;
    @Value("${elasticsearch.port}")
    private int port;



    @Bean
    public RestHighLevelClient esRestClient() {
        RestHighLevelClient http = new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost(host, port, "http")));
        return http;
    }
}
